package com.googlecode.particlesys.templates;

import java.awt.Color;

import com.googlecode.particlesys.objects.AbstractEmitter;
import com.googlecode.particlesys.objects.Particle;

public class Shooter extends AbstractEmitter {
	
	private boolean dir = false;
	private final int sx;

	public Shooter(int x, int y){
		super(5, 5, x, y, 1, 0);
		this.sx = x;
	}
	
	@Override
	public void step(){		
		if(dir){
			x += 3;
			
			if(x > sx){
				dir = false;
			}
		} else {
			x -= 3;
			
			if(x < sx-200){
				dir = true;
			}
		}
	}

	@Override
	public Particle getNextParticle(){
		Particle p = new Particle(Color.WHITE, width, height*2);
		p.setX(x);
		p.setY(y);
		p.setSpeed(10);
		p.setAngle(90);
		p.setLife(15);
		return p;
	}
}